import { apiClient } from './axios';

// 人员管理相关接口
export const personnelApi = {
  // 获取人员列表
  getPersonnel: (params?: {
    page?: number;
    per_page?: number;
    search?: string;
    position?: string;
    area_id?: number;
    is_active?: boolean;
  }) => {
    return apiClient.get('/personnel', { params });
  },

  // 获取单个人员详情
  getPersonnelById: (personnelId: number) => {
    return apiClient.get(`/personnel/${personnelId}`);
  },

  // 创建人员
  createPersonnel: (personnelData: {
    name: string;
    employee_id?: string;
    position?: string;
    phone?: string;
    email?: string;
    area_id?: number;
    hire_date?: string;
    is_active?: boolean;
    notes?: string;
  }) => {
    return apiClient.post('/personnel', personnelData);
  },

  // 更新人员
  updatePersonnel: (personnelId: number, personnelData: {
    name?: string;
    employee_id?: string;
    position?: string;
    phone?: string;
    email?: string;
    area_id?: number;
    hire_date?: string;
    is_active?: boolean;
    notes?: string;
  }) => {
    return apiClient.put(`/personnel/${personnelId}`, personnelData);
  },

  // 删除人员
  deletePersonnel: (personnelId: number) => {
    return apiClient.delete(`/personnel/${personnelId}`);
  },

  // 获取人员选项列表（用于下拉选择）
  getPersonnelOptions: (params?: { position?: string; area_id?: number }) => {
    return apiClient.get('/personnel/options', { params });
  },

  // 切换人员状态
  togglePersonnelStatus: (personnelId: number) => {
    return apiClient.put(`/personnel/${personnelId}/toggle-status`);
  }
};